import syslog2reg

class Manager(object):
    def testFunc0(self):
        str1 = '<318>Sep 23 11:58:25 down FILTER: SerialNum=10041-01192-2000H-J34G9-0441O GenTime="2016-09-23 11:58:25" SrcIP=172.20.21.130 DstIP=202.106.0.20 Protocol=UDP SrcPort=65332 DstPort=53 InInterface=ge0/4 OutInterface=ge0/3 FwPolicyID=1 Action=PERMIT Content="POLICY*: The packet was through because the firewall policy is permit"'
        str2 = '<965>JUL 17 09:04:08 127.0.0.1 ORACLE: devsn=0616201506019998 gen_time=2015-07-17 09:04:08 id=7464895826260736 session_id=7464728859499264 transport_protocol=tcp app_protocol=ORACLE level=high dev_ip=127.0.0.1 server_ip=192.168.171.16 client_ip=192.168.171.223 server_port=1521 redirect_port=1521 client_port=56287 server_mac=00-0C-29-F9-62-AE client_mac=00-0C-29-22-F4-F5 ruleset_name=ANY rule_name=ANY bizaccout= auth_account= policy_id=1 rule_id=11 rule_templet_id=36000 direction=response response_time=381 error_code=0 block=no record_rows=0 sql=SELECT * FROM WM_WARNINGCONFIG WHERE USERID = :1 client_host= server_host= library= client_software= client_user= instance_name= db_name= table_name=WM_WARNINGCONFIG object_name= cmd=1004 subcmd=where CVEID=1'
        # {MARK}|DPort=$14|Proto=$8,,1|SPort=$16|DIP=$12|SIP=$13|DevID=$4|DevTime=$1|RawEventName=$4|RawID=$6|RawLevel=$10|Level=$10,,1|EventType=$19,,1|DevIP=$11|DevIPV6={DEVIP}|DevType={DEVTYPE}|Purpose=4|Count=1|Result=3|LongComment={RAW}

        ae = syslog2reg.ActionExtractor()
        pc = syslog2reg.PatConvertor()

        patternStr = pc.convert(str1)
        actStr = ae.autoAct(str1)

        syslog2reg.XmlBuilder.setPara({'Pattern': patternStr, 'Action': actStr}, syslog2reg.NodeType.Rul)

        xml = syslog2reg.XmlBuilder()
        xml.buildStructure()